﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.ServiceModel.Description;
using System.Data.Services;

namespace RemoteHardwareMonitor
{
    /// <summary>
    /// Creates and runs a singleton instance of RemoteHardwareMonitorService
    /// </summary>
    class WCFHttpProvider
    {
        Type serviceType = typeof(RemoteHardwareMonitorService);
        // not sure why this still works when the host IP is different? 
        Uri baseAddess = new Uri("http://192.168.1.103:8080/index");
        WebServiceHost host;

        public WCFHttpProvider()
        {
                    Uri[] baseAddress =  {baseAddess};
                    RemoteHardwareMonitorService rHMS = new RemoteHardwareMonitorService();

                    host = new WebServiceHost(rHMS, baseAddress);

                    ServiceEndpoint endPoint = host.AddServiceEndpoint(typeof(IHardwareMonSrvce), new WebHttpBinding(), "");
                    Start();
 
        }

        public void Stop()
        {
            host.Close();
        }
        

        private void Start()
        {
            host.Open();
            
            Console.WriteLine("service running");
        }

    }
}
